<div class="box nomtop">
<h1><?php echo $this->translate( 'registration_form' ) ?></h1>

<?php if( $this->regok ) { ?>
<div class="content">
	<?php echo $this->translate( 'regok' ); ?>
</div>
<?php } else if( $this->regok2 ) { ?>
<div class="content">
	<?php echo $this->translate( 'regok2' ); ?>
</div>
<?php } else { ?>
	<?php echo $this->inlineScript()->setScript('
	$(document).ready(function(){
	$.validator.addMethod("nameRegex", 
		function(value, element) {
        	return this.optional(element) || /^[^0-9]+$/i.test(value);
    }, 
    "Możesz używać tylko liter.");

	$.validator.addMethod("zipRegex", 
		function(value, element) {
        	return this.optional(element) || /^\d{2}-\d{3}$/i.test(value);
    }, 
    "Zly kod pocztowy.");
    
	$.validator.addMethod("telRegex", 
		function(value, element) {
        	return this.optional(element) || /^[0-9\-\ \(\)\+]+$/i.test(value);
    }, 
    "' . $this->translate( 'error_phone' ) . '");
    
    $.validator.addMethod("bdRegex", 
		function(value, element) {
        	return (value < 32) ? true : false;
    }, 
    "' . $this->translate( 'club_error_birthday_day' ) . '");
   
    $.validator.addMethod("bmRegex", 
		function(value, element) {
        	return (value < 13) ? true : false;
    }, 
    "' . $this->translate( 'club_error_birthday_month' ) . '");
    
    $.validator.addMethod("byRegex", 
		function(value, element) {
        	return (value > 1900 && value <= (new Date).getFullYear()) ? true : false;
    }, 
    "' . $this->translate( 'club_error_birthday_year' ) . '");
    
		$("#reg-form").validate({
			rules: {
				name : {
					required: true,
					minlength: 2,
					maxlength:250,
					nameRegex: true
															
				},
				surname : {
					required: true,
					minlength: 2,
					maxlength:250,
					nameRegex: true
				},
				email : {
					required: true,
					maxlength:255,
					email: true
				},
				pass : {
					required: true,
					minlength: 5
				},
				password_retype : {
					required: true,
					minlength: 5,
					equalTo: "#cpass"
				}, 
				phone : {
					minlength: 7,
					maxlength: 30,
					telRegex: true
				},
				zip : {
					minlength: 5,
					maxlength:10
				},
				locality : {
					required: true,
					maxlength:250,
					minlength: 5,
					nameRegex: true
				},
				street : {
					required: true,
					maxlength:255,
					minlength: 2
				},
				nr_home : {
					required: true,
					maxlength:10
				},
				nr_flat : {
					maxlength:10
				},
				rules : {
					required: true
				},
				rules2 : {
					required: true
				},
				birthday_day : {
					required: true,
					minlength: 1,
					number:true,
					maxlength: 2,
					bdRegex: true
				},
				birthday_month : {
					required: true,
					minlength: 2,
					number:true,
					maxlength: 2,
					bmRegex: true
				},
				birthday_year : {
					required: true,
					minlength: 4,
					number:true,
					maxlength: 4,
					byRegex: true
				}
			},
			messages: {
				name : "' . $this->translate( 'error_name' ) . '",
				surname : "' . $this->translate( 'error_surname' ) . '",
				email : "' . $this->translate( 'error_email' ) . '",
				pass : "'. $this->translate( 'error_password' ) .'",
				password_retype : "'. $this->translate( 'error_retype_password' ) .'",
				phone : "' . $this->translate( 'error_phone' ) . '",
				street : "' . $this->translate( 'error_street' ) . '",
				locality : "' . $this->translate( 'error_locality' ) . '",
				nr_home : "' . $this->translate( 'error_nr_home' ) . '",
				rules : "' . $this->translate( 'error_rules' ) . '",
				rules2 : "' . $this->translate( 'error_rules2' ) . '",
				birthday_day : "' . $this->translate( 'club_error_birthday_day' ) . '",
				birthday_month : "' . $this->translate( 'club_error_birthday_month' ) . '",
				birthday_year : "' . $this->translate( 'club_error_birthday_year' ) . '"
			}
		});
		
		$("#boxstylishcountry").change(function(){

			if( $(this).val() != "PL" ) {
				$("#boxstylishprovince").animate({ opacity: 0 });
			} else {
				$("#boxstylishprovince").animate({ opacity: 1 });
			}
		
		});
	});
	'); ?>
	
	
	<form id="reg-form" method="post" action="">
	<input type="hidden" name="parent_u_id" value="<?php echo $this->agentId ?>" />
	<table class="tab">
		<tr>
			<td class="aright"><?php echo $this->translate( 'company_name' ); ?>:</td>
			<td><input type="text" name="company_name" value="<?php echo $this->company_name ?>"></td>
		</tr>
		<tr>
			<td class="aright"><?php echo $this->translate( 'nip' ); ?>:</td>
			<td><input type="text" id="cnip" name="nip" value="<?php echo $this->nip ?>"></td>
		</tr>
		<tr>
			<td class="aright"><span class="star">*</span><?php echo $this->translate( 'name' ); ?>:</td>
			<td><input type="text" id="cname" name="name" value="<?php echo $this->name ?>"></td>
		</tr>
		<tr>
			<td class="aright"><span class="star">*</span><?php echo $this->translate( 'surname' ); ?>:</td>
			<td><input type="text" id="csurname" name="surname" value="<?php echo $this->surname ?>"></td>
		</tr>
		<tr>
			<td class="aright"><span class="star">*</span><?php echo $this->translate( 'email' ); ?>:</td>
			<td>
			<input type="text" id="cemail" name="email" value="<?php echo $this->email ?>">
			<?php if( $this->error_email ) { ?>
				<label class="error"><?php echo $this->translate( 'duplicate_email' ); ?></label>
			<?php } ?>
			</td>
		</tr>
		<tr>
			<td class="aright"><?php echo $this->translate( 'phone' ); ?>:</td>
			<td><input type="text" id="cphone" name="phone" value="<?php echo $this->phone ?>"></td>
		</tr>
		<tr>
			<td class="aright"><span class="star">*</span><?php echo $this->translate( 'birthday' ); ?>:</td>
			<td>
				<input type="text" name="birthday_day" value="<?php echo $this->birthday_day ?>" maxlength="2" style="width:30px"> /
				<input type="text" name="birthday_month" value="<?php echo $this->birthday_month ?>" maxlength="2" style="width:30px"> /
				<input type="text" name="birthday_year" value="<?php echo $this->birthday_year ?>" maxlength="4" style="width:30px">
			</td>
		</tr>
		<tr>
			<td class="aright"><span class="star">*</span><?php echo $this->translate( 'locality' ); ?>:</td>
			<td><input type="text" id="clocality" name="locality" value="<?php echo $this->locality ?>"></td>
		</tr>
		<tr>
			<td class="aright"><span class="star">*</span><?php echo $this->translate( 'street' ); ?>:</td>
			<td><input type="text" id="cstreet" name="street" value="<?php echo $this->street ?>"></td>
		</tr>
		<tr>
			<td class="aright"><span class="star">*</span><?php echo $this->translate( 'nr_home_reg' ); ?>:</td>
			<td><input type="text" name="nr_home" value="<?php echo $this->nr_home ?>"></td>
		</tr>
		<tr>
			<td class="aright"><?php echo $this->translate( 'nr_flat_reg' ); ?>:</td>
			<td><input type="text" name="nr_flat" value="<?php echo $this->nr_flat ?>"></td>
		</tr>
		<tr>
			<td class="aright"><?php echo $this->translate( 'zip' ); ?>:</td>
			<td><input type="text" id="czip" name="zip" value="<?php echo $this->zip ?>"></td>
		</tr>
		<tr>
			<td class="aright"><?php echo $this->translate( 'province' ); ?>:</td>
			<td><?php  echo $this->formSelect( 'province', $this->province, array(
					'id' => 'boxstylishprovince'
				), Core_Static::$province ) ?></td>
		</tr>
		<tr>
			<td class="aright"><?php echo $this->translate( 'country' ); ?>:</td>
			<td><?php echo $this->formSelect( 'country', ( $this->country ) ? $this->country : 'PL', array(
					'id' => 'boxstylishcountry'
				), Core_Static::$country ) ?>
				<?php echo $this->inlineScript()->setScript( '
				$( "#country" ).change(function(){
					
					if( $(this).val() != "PL" ) {
						$( "#boxstylishprovince" ).animate({ opacity: 0 });
					} else {
						$( "#boxstylishprovince" ).animate({ opacity: 1 });
					}
	
				});
			' ); ?>	
			</td>
		</tr>
		<tr>
			<td class="aright"><span class="star">*</span><?php echo $this->translate( 'password' ); ?>:</td>
			<td>
				<input type="password" id="cpass" name="pass" value="" >
				<?php if( $this->pass_empty ) { ?>
					<label class="error"><?php echo $this->translate( 'error_password' ); ?></label>
				<?php } ?>
			</td>
		</tr>
		<tr>
			<td class="aright"><span class="star">*</span><?php echo $this->translate( 'password_retype' ); ?>:</td>
			<td>
				<input type="password" id="cpassword_retype" name="password_retype" value="" >
				<?php if( $this->pass_retypeinvalid ) { ?>
					<label class="error"><?php echo $this->translate( 'error_retype_password' ); ?></label>
				<?php } ?>
			</td>
		</tr>
		<tr>
			<td class="aright"></td>
			<td>
				<p>
					<input type="checkbox" id="crules" name="rules" value=""><label for="crules"></label>
					<?php echo $this->translate( 'rules' ); ?> <a target="_blank" href="{baseUrl}/index/static/p/rules">regulaminu</a>
					<?php if( $this->rules_empty ) { ?>
						<label class="error"><?php echo $this->translate( 'error_rules' ); ?></label>
					<?php } ?>
				</p>
				<p>
					<input type="checkbox" id="crules2" name="rules2" value=""><label for="crules2"></label>
					<?php echo $this->translate( 'rules2' ); ?>
				</p>
			</td>
		</tr>
		
		</table>
	</form>
	<div class="line" style="margin:10px 0"></div>
	<div class="acenter">
	<a href="javascript:;" class="button" onclick="$('#reg-form').submit()"><?php echo $this->translate( 'save' ); ?></a>
	</div>
	<div class="end"></div>
	</div>
<?php } ?>